#ifndef _UTIL_H_
#define _UTIL_H_

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <pthread.h>
#include <sys/shm.h>
#include <search.h>
#include <sys/ipc.h>
#include <errno.h>
#include <semaphore.h>
#include <stdarg.h>
#include <mysql.h>
#include <ctype.h>

typedef struct 
{
    int fd;
    sem_t sem;
    int flags;
    
} log_t;
log_t *log, *flog;

#define BAD 0
#define DEBUG 1
#define INFO  2
#define WARN  3
#define ERROR 4
#define FATAL 5

#define LOGLINE_MAX 1024
#define	MAX_BUF_SIZE	10240

int lprintf( log_t *log, unsigned int level, char *fmt,...);

#define LOG_TRUNC   1<<0
#define LOG_NODATE  1<<1
#define LOG_NOLF    1<<2
#define LOG_NOLVL   1<<3
#define LOG_DEBUG   1<<4
#define LOG_STDERR  1<<5
#define LOG_NOTID   1<<6

log_t *log_open( char *fname, int flags );
void log_close( log_t *log );
int lprintf( log_t *log, unsigned int level, char *fmt,...);
#endif

